package com.example.demo.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@Controller
//@ResponseBody
//@RestController
@RequestMapping("/p")
public class PersonController {
//    @RequestMapping("/index")
//    public Object index() {
//// 执⾏业务...
//// 返回view -> index.html
//        return "/index.html";
//    }


    @RequestMapping("/meth")
    public String method() {
        return "Hello,HTML ！";
    }


    @RequestMapping("/jsonmap")
    public HashMap<String, String> jsonMap() {
        HashMap<String, String> map = new HashMap<>();
        map.put("Java", "Java Value");
        map.put("MySQL", "MySQL Value");
        map.put("Redis", "Redis Value");
        return map;
    }

    // 请求转发
    @RequestMapping("/forward")
    public String forwardMethod(){
        return "redirect:/index.html";
    }

    // 请求重定向
    @RequestMapping("/redirect")
    public String redirectMethod(){
        return "redirect:/index.html";
    }
}
